#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

int main(int argc, char **argv)
{
    cv::namedWindow("Example3", cv::WINDOW_AUTOSIZE);
    cv::VideoCapture cap;
    cap.open(std::string(argv[1]));

    // Get the original width and height of the video
    int original_width = static_cast<int>(cap.get(cv::CAP_PROP_FRAME_WIDTH));
    int original_height = static_cast<int>(cap.get(cv::CAP_PROP_FRAME_HEIGHT));

    // Define the scale factor
    double scale_factor = 0.5;

    // Calculate the new width and height
    int new_width = static_cast<int>(original_width * scale_factor);
    int new_height = static_cast<int>(original_height * scale_factor);

    cv::Mat frame, resized_frame;
    while (1)
    {
        cap >> frame;
        if (frame.empty())
            break;  // Ran out of film
        cv::resize(frame, resized_frame, cv::Size(new_width, new_height));
        cv::imshow("Example3", resized_frame);
        if (cv::waitKey(33) >= 0)
            break;
    }
    cv::destroyWindow("Example3");
    return 0;
}
